package us.wili.dev.common.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by JasonY on 17/7/7.
 */
public class Module {

    private String key;
    private String name;
    private Boolean selected;
    private Map<String, Permission> permissions;
    private List<Permission> plist;

    public void setPlist(List<Permission> plist) {
        this.plist = plist;
    }

    public List<Permission> getPlist() {
        if (plist == null || plist.isEmpty()) {
            if (permissions == null || permissions.isEmpty()) {
                return null;
            }

            return new ArrayList<>(permissions.values());
        }

        return plist;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Map<String, Permission> getPermissions() {
        return permissions;
    }

    public void setPermissions(Map<String, Permission> permissions) {
        this.permissions = permissions;
    }

    public Boolean getSelected() {
        return selected;
    }

    public void setSelected(Boolean selected) {
        this.selected = selected;
    }
}
